# Replication files for Dinesen Peter Thisted; Schaeffer, Merlin, Sønderskov, Kim Mannemar: "Ethnic Diversity and Social Trust. A Narrative and Meta-Analytical Review", forthcoming in *Annual Review of Political Science*, Volume 23, 2020

In this document, we give a brief overview of the replication files for our article and some general instructions for using them. The individual do-files and R scripts include comments providing further details and orientation. To use the replication files, you need a working version of R, as well as Stata (we used Stata Version 15.1). Note that, as reproducibility may also depend on the version of R and the various packages used, we included a screenshot of the R session info for our simulations with the replication materials (see the file `sessionInfo.png`). Further note that you will first need to install Xcode from the Mac App Store if you use a Mac.

The sub-folder "scripts" contains all necessary Stata do-files and R-scripts to reproduce Figures 1 to 4 and all results reported in the running text of the main article, as well as all results and Figures reported in the Online Supplement. Please proceed as follows to replicate the results:

1. Install the following R packages from CRAN:
```{r}
install.packages(
    c("tidyverse", "haven", "metafor",
        "ggplot2", "texreg", "lme4"), dependencies = TRUE
    )
```
2. Install the latest GitHub development version of the R package "broom" (0.5.2.9002). One way to do this is to install and use the R package "devtools":
```{r}
install.packages("devtools")
library(devtools)
devtools::install_github("tidymodels/broom")
```
If you cannot get "devtools" to work, you can also try to use the R package "remote" instead:
```{r}
install.packages("remotes")
library(remotes)
remotes::install_github("tidyverse/broom")
```
3. Open the R-script "Replicationfiles/scripts/main_analysis.R". Assign the path `YOURPATH/Replicationfiles/` to the object `loc`, where "YOURPATH" refers to the appropriate directory on your computer.
4. Mark all and run.
5. Open the Stata do-file "GenerateTablesD1-D3.do". Define the working directory `cd YOURPATH/Replicationfiles/`, where "YOURPATH" refers to the appropriate directory on your computer.
6. Mark all and run.
7. You can find the results in the sub-folders "figures" and "tables". Some results which we mention in the running text of the main article and the Online Supplement can be found in the model output displayed by R. The R-script "Replicationfiles/scripts/main_analysis.R" mentions which lines produce the respective output.
